home *** CD-ROM | disk | FTP | other *** search
/ Amiga Developer CD 2.1 / Amiga Developer CD v2.1.iso / NDK / NDK_1.3 / Read-Me1.3 / Workbench1.3 / IEEE < prev    next >
Encoding:
Text File  |  1988-02-11  |  9.4 KB  |  218 lines

  1.  
  2.         Introduction to 1.3 IEEE Double Precision Libraries
  3.         ===================================================
  4.  
  5. Notes:
  6.  
  7.    1. This article refers to several files found on other disks:
  8.  
  9.          Libraries in LIBS directory of Workbench1.3
  10.               mathieeedoubbas.library
  11.               mathieedoubtrans.library
  12.  
  13.          Linker Libraries in LIB directory of Include.strip
  14.               mathieeedoubbas_lib.lib
  15.               mathieeedoubtrans_lib.lib
  16.  
  17.          FD files in FD1.3 directory of Extras1.3
  18.               mathieeedoubbas_lib.fd
  19.               mathieeedoubtrans_lib.fd
  20.  
  21.  
  22.    2. This article was written for the Beta2 ieee libraries.
  23.       The libraries on Workbench1.3g4 are a later version.
  24.  
  25.    3. Every task must open these libraries themselves rather
  26.       than sharing library bases to insure the 68881 is properly
  27.       initialized for each task.
  28.       
  29.  
  30. The basic double precision IEEE library has been rewritten for 1.3
  31. The new library is up to seven times faster than the old one and
  32. averages twice as fast for +,-,*,/.  It more properly handles
  33. degenerate cases like NotANumber, Infinity, and denormalized numbers.
  34. There is a table of approximate speed-ups per function at the end
  35. of this article.
  36.  
  37. Besides the faster software emulation of floating point, this
  38. library recognizes and uses the 68020/68881* combination and
  39. will use the floating point instructions available. Also, if an
  40. preexisting math resource** is available it will use that as well.
  41. Normally this resource will point to the base of a 68881 designed
  42. as a 16 bit i/o port, but maybe a different device instead.
  43. We also provide the ability to programmatically trap math errors such
  44. as overflow and divide by zero. Your program can now ignore them
  45. or take suitable action without visiting the GURU.
  46.  
  47. A brand new library has been written for 1.3. It is the IEEE
  48. double precision transcendental library. It supports the same functions
  49. as the transcendental library for the Motorola fast floating point.
  50. This library also identifies and uses the 68020/68881 combination as
  51. well as the math resource. It has a very fast software square root routine.
  52.  
  53. Why should you use these libraries?
  54.  
  55. These libraries are highly optimized and provide very fast emulation
  56. of IEEE double functions.
  57.  
  58. Your code can share the IEEE libraries with other applications.
  59. This saves 16k bytes per user with the transcendental library.
  60.  
  61. If you need the precision of IEEE double, and wish to have a transparent
  62. improvement in speed when your programs run on machines with math
  63. coprocessors, then you should use these libraries. All the decision
  64. making is done by the library when it is first initialized and it will
  65. use the fastest available resources to do your math. You only need
  66. one program to support a standard Amiga, a 68020/68881 Amiga, or an
  67. external math coprocessor Amiga.
  68.  
  69. Why wouldn't you use these libraries?
  70.  
  71. For ultimate speed on a 68020/68881 system, you will want to use
  72. the new instructions available from the 68020/68881 directly in
  73. your code. This, however, prevents your code from running on conventional
  74. 68000 powered Amigas. In this case, you may need to supply different
  75. versions of your code, one for each different configuration.
  76.  
  77. These libraries should be placed in the libs: directory.
  78. The basic library will replace the old library, and the transcendental
  79. library is an addition.
  80.  
  81. For programmers there are additional files to link with as well as
  82. a new .fd file for the transcendental functions.
  83.  
  84. * There are several manufactures of 68020/68881 upgrade boards such
  85.   as CSA. Commodore-Amiga has also announced such a product.
  86.  
  87. ** Math Resources have been announced by Microbotics and ASDG.
  88.  
  89.  
  90.  
  91. Hardware Developer information.
  92.  
  93. To make use of CBM's standard peripheral support for 68881 you
  94. must design your peripheral to autoconfig. Your autoconfig
  95. software must create a resource and add it to the resource list.
  96. The name of this resource is "MathIEEE.resource".
  97. The IEEE library will attempt to open this resource. If it finds it,
  98. it will extract the BaseAddr pointer and copy it into its library
  99. structure. If the BaseAddr pointer is non-null it will use a different
  100. list of routine entry points when the IEEE library is initialized.
  101.  
  102. After the IEEE library is initialized, the library again checks the
  103. resource for alternate function bits in Flags of the resource. The Basic
  104. library only checks the
  105. DblBasAlt bit, and the transcendental library only checks the
  106. DblTransAlt bit. If they are set, the library routine will call the
  107. function whose address is in the corresponding Init field.
  108. The arguments passed are a6 = sysbase,a1=resource,a2=mathlibrary.
  109.  
  110. If your device is not a 68881 then you may need to use this.
  111. There are separate bits for different library capabilities in case
  112. your math resource is only able to handle a limited set of functions.
  113. This will let you tie a math processor in that may only provide
  114. add/subtract/multiply/divide. The rest of software  will
  115. use it transparently by calling your alternate routines.
  116.  
  117. Amiga does not provide for arbitrating a math accelerator in
  118. a multitasking environment. So you must provide some support there
  119. when your device autoconfigs. The only exception is the 68020/68881
  120. combination where support for that has been standard since V1.2
  121. Arbitration usually involves saving and restoring the state of you
  122. hardware device between task switches.
  123.  
  124. We recommend that you look at the tc_Switch/tc_Launch vectors in
  125. the task data structure. These are called each time control transfers
  126. from one task to another. And remember not to assume that you are
  127. the only process needing to use those vectors.
  128.  
  129. The resource data structure is as follows:
  130.  
  131.  STRUCTURE  MathIEEE,LN_SIZE
  132.         UWORD   MathIEEE_Flags
  133.         ULONG   MathIEEE_BaseAddr       ; for standard 68881 support
  134.         ULONG   MathIEEE_DblBasInit     ; something else besides 68881
  135.         ULONG   MathIEEE_DblTransInit   ; something else besides 68881
  136.         ULONG   MathIEEE_SnglBasInit    ; something else besides 68881
  137.         ULONG   MathIEEE_SnglTransInit  ; something else besides 68881
  138.  LABEL  MathIEEE_sizeof
  139.  
  140. * the MathIEEE resource structure may grow in the future. Extensions
  141. * will be added only as Amiga may define new capabilities. Such
  142. * as 80 bit extended format.
  143.  
  144. *       bits for MathIEEE_flags
  145. *       all unassigned bits must be 0
  146.         BITDEF  MathIEEE,DblBasAlt,0            ; alternate Basic library
  147.         BITDEF  MathIEEE,DblTransAlt,1          ; alternate Trans library
  148.         BITDEF  MathIEEE,SnglBasAlt,2           ; alternate Basic library
  149.         BITDEF  MathIEEE,SnglTransAlt,3         ; alternate Trans library
  150.  
  151. *       The 'Init' entries are only used if the corresponding
  152. *       Bit is set in the Flags field
  153. *       So if you are just a 68881, you do not need the Init stuff
  154. *       just make sure you have cleared the Flags field
  155. *       This should allow us to add Extended Precision later
  156. *       For Init users, make sure you splice yourself into the
  157. *       Open/Close/Expunge vectors for this library
  158.  
  159. The library structure that is used is tentatively laid out this way.
  160. I say tentatively because the name of the entries may change yet, but
  161. I will not change their order, usage, or size.
  162. Naturally we  may add stuff to the end.
  163.  
  164.     STRUCTURE  MI,LIB_SIZE      ; Standard library node
  165.         UBYTE   io8_Flags       ; is this 68881?
  166.         UBYTE   io8_pad         ; line up to next 32bit boundary
  167.         ULONG   io8_68881       ; ptr to io68881 base
  168.         ULONG   io8_SysLib      ; ptr to SysBase
  169.         ULONG   io8_SegList     ; ptr to this SegList
  170.         ULONG   io8_Resource    ; ptr to mathIEEE.resource
  171.         ULONG   io8_opentask    ; called when task opens
  172.         ULONG   io8_closetask   ; called when task closes
  173.     LABEL   MI_SIZE
  174.  
  175. Of particular interest to hardware developers are the opentask/closetask
  176. entry points. These functions will be called when a task calls
  177. OpenLibrary and CloseLibrary. This will give the vendor the opportunity
  178. to set up any per task initialization necessary. The Amiga library
  179. presently sets them up as NOPs in the case of straight emulation.
  180. It puts the 68881 initialization stuff in there for 68020/68881 as well
  181. as the peripheral 68881. That initialization stuff currently sets up
  182. rounding modes and interrupt requests.
  183. If you need to override the defaults, you will have to set the appropriate
  184. Alt bits in the Resource structure and overwrite the opentask/closetask
  185. fields when your AltInit function is called. The OpenLibrary routine
  186. checks the return value of opentask for errors. If a nonzero is in d0.l
  187. then OpenLibrary will return 0 to the task trying to OpenLibrary.
  188.  
  189. Table of Approximate Speed Ups from 1.2 to 1.3
  190. --------------------------------------------------
  191. Function          Times faster in 1.3/68000     
  192. ==================================================
  193. IEEEDPFlt      2.1
  194. IEEEDPFix      5.01
  195. IEEEDPAbs      1.6
  196. IEEEDPNeg      2.9
  197. IEEEDPTst      2.7
  198. IEEEDPFloor      7.6
  199. IEEEDPCeil      7.2
  200. IEEEDPCmp      2.8
  201. IEEEDPAdd      1.9
  202. IEEEDPSub      1.8
  203. IEEEDPMul      2.1
  204. IEEEDPDiv      2.1
  205.  
  206. Of course, your mileage may vary.
  207.  
  208. A 68010 improved results about 5% for multiply and about 9% for divide.
  209.  
  210.  
  211. On the 68020/68881 some new exceptions are generated. Unfortunately
  212. the V1.2 os does not properly initialize these. For users of the new
  213. ramkick/A2024 system, the fixes have been added to the exec.library.
  214. For the rest we provide a program to run during your startup sequence
  215. to initialize the vectors and redirect processing back to exec when
  216. the new exceptions occur. This is only necessary on 68020/68881 systems.
  217.  
  218.